"""
关于函数的使用
"""


def person(name, age, sex):
    """
    普通参数
    :param name:姓名
    :param age:年龄
    :param sex:性别
    :return:
    """
    print("我叫{},我今年{}岁，我是个{}".format(name, age, sex))


def person(name, age, sex, type="成人"):
    """
    默认参数1
    :param name:
    :param age:
    :param sex:
    :param type:
    :return:
    """
    print("我叫{},我今年{}岁，我是个{},我是{}".format(name, age, sex, type))


def person_more(name, age, sex, *args):
    """
    接收多个任意参数
    :param name:
    :param age:
    :param sex:
    :param args:
    :return:
    """
    print("我叫{},我今年{}岁，我是个{}".format(name, age, sex))
    print("args的数据类型是{}".format(type(args)))
    for param in args:
        print("参数类型:{},参数值:{}".format(type(param), param))


def person_more2(name, age, sex, **kvargs):
    """
    接收多个任意参数,接收key-value参数
    :param name:
    :param age:
    :param sex:
    :param args:
    :return:
    """
    print("我叫{},我今年{}岁，我是个{}".format(name, age, sex))
    for k, v in kvargs.items():
        print("参数类型:{},参数key:{},参数value:{}".format(type(kvargs), k, v))


# 函数的调用
# 位置实参
person("妲己", 1000, "male")
# 参数默认值
person("妲己", 1000, "male", type="宝宝")
# person("妲己", type="宝宝", 1000, "male")

# 关键字形参
person(name="甄姬", type="宝宝", age=25, sex="female")
print("*" * 30)
print("收集参数调用--传入非字典值")
person_more("后羿", 12, "male", "射日", "嫦娥", "烧饼", 9)
lst = ["射日", "嫦娥", "烧饼", 9]
print("收集参数调用--将list传入,同时自动解包list中的元素")
person_more("后羿", 12, "male", *lst)
person_more("后羿", 12, "male", lst)
print("*" * 30)
print("收集参数调用--传入字典值")
person_more2("后羿", 12, "male", work="射日", lover="嫦娥", food="烧饼", lucky_num=9)
